<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style>
		#answer{margin:100px auto;width:1000px;}
	</style>
</head>
<body>
	<div id="answer">
		<input type="checkbox" name="answer" value=1>A
		<input type="checkbox" name="answer" value=2>B
		<input type="checkbox" name="answer" value=3>C
		<input type="checkbox" name="answer" value=4>D
		<input type="checkbox" name="answer" value=5>E
		<br><br><br><br>
		<button onclick="checkAll()" >全选</button>
		<button onclick="channelAll()" >全取</button>
		<button onclick="checkF()" >全反</button>
		<button onclick="show()" >取值</button>
	</div>
	<p>
	<p>
	<div id="show"></div>
</body>
	<script>
		var ans = document.getElementById("answer");

		var ins = ans.getElementsByTagName("input");

		function checkAll()
		{
			for(var i=0;i<ins.length;i++)
			{
				ins[i].checked = true;
			}
		}

		function channelAll()
		{
			for(var i=0;i<ins.length;i++)
			{
				ins[i].checked = false;
			}
		}

		function checkF()
		{
			for(var i=0;i<ins.length;i++)
			{
				ins[i].checked = ins[i].checked==true?false:true;
			}
		}

		function show()
		{
			var res = [];

			for(var i=0;i<ins.length;i++)
			{
				if(ins[i].checked)
				{
					res.push(ins[i].value);
				}
			}

			document.getElementById("show").innerHTML = res.join();
		}

	</script>
</html>